﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using System.Net;

using EHTWebsite.Code;
using EHTWebsiteProject.Code.BLL;
using System.Resources;
using System.Threading;
using System.Globalization;
using System.Text;
using Telerik.Web.UI;
using System.Collections.Generic;
using EHTWebsiteProject.Code.Entity;
namespace EHTWebsiteProject.Administrator
{
    public partial class EHTConfigCategory : System.Web.UI.Page
    {
        public Boolean IsVN = true;
        private String Loai = "";
        private String languageCode = "vi-VN";
        private ResourceManager rm = new ResourceManager("Resources.SiteMap", System.Reflection.Assembly.Load("App_GlobalResources"));

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {

                try
                {
                    languageCode = Session[HangSo.LANGUAGE_CODE].ToString();
                    if (languageCode == "en-us")
                    {
                        IsVN = false;
                    }

                }
                catch (Exception ex)
                {
                }

                Thread.CurrentThread.CurrentCulture = new CultureInfo(languageCode);
                LoadLanguage(Thread.CurrentThread.CurrentCulture);
            }
        }

        /// <summary>
        /// Ham load ngon ngu
        /// </summary>
        /// <param name="ci"></param>
        public void LoadLanguage(CultureInfo ci)
        {
            lbSave.Text = rm.GetString("lbSave", ci);
            lbBack.Text = rm.GetString("lbBack", ci);
            lbParameters_Advanced.Text = rm.GetString("lbParameters_Advanced", ci);
            lbParameters_Basic.Text = rm.GetString("lbParameters_Basic", ci);
            lbConfig.Text = rm.GetString("lbConfig", ci);
            lbTenNhom.Text = rm.GetString("lbTenNhom",ci);
            lbMota.Text = rm.GetString("lbMota", ci);

            lbColumn.Text = rm.GetString("lbColumn", ci);
            lbDisplaysize.Text = rm.GetString("lbDisplaysize", ci);
            lbDisplaythumbnail.Text = rm.GetString("lbDisplaythumbnail", ci);
            lbWidthofThumb.Text = rm.GetString("lbWidthofThumb", ci);
            rbDisplay_No.Text = rm.GetString("rbDisplay_No", ci);
            rbDisplay_Yes.Text = rm.GetString("rbDisplay_Yes", ci);
            rbMoTa_Hide.Text = rm.GetString("rbMoTa_Hide", ci);
            rbMoTa_Show.Text = rm.GetString("rbMoTa_Show", ci);
            rbTenNhom_Hide.Text = rm.GetString("rbTenNhom_Hide", ci);
            rbTenNhom_Show.Text = rm.GetString("rbTenNhom_Show", ci);
            rbthum_No.Text = rm.GetString("rbthum_No", ci);
            rbthum_Yes.Text = rm.GetString("rbthum_Yes", ci);
           


        }

        public ParaGroupProducts GetParaGroupProducts(ParaGroupProducts theParaGroupProducts)
        {            
                theParaGroupProducts.GroupName = rbTenNhom_Show.Checked.ToString();           
                theParaGroupProducts.Hover = rbDisplay_Yes.Checked.ToString();          
                theParaGroupProducts.Description = rbMoTa_Show.Checked.ToString();           
                theParaGroupProducts.DisplayThumb = rbthum_Yes.Checked.ToString();
            try
            {
                theParaGroupProducts.Columns = Int32.Parse(txtColumns.Text);
            }
            catch
            {
                theParaGroupProducts.Columns = 3;
            }

            try
            {
                theParaGroupProducts.NumIntro = 1;
            }
            catch
            {
                theParaGroupProducts.NumIntro = 1;
            }
            theParaGroupProducts.ImgAlign = "";
            theParaGroupProducts.Pagination = "";
            if(txtWidthOfthumbs.Text == "")
                theParaGroupProducts.WidthThumb = "0";
            else
                theParaGroupProducts.WidthThumb = txtWidthOfthumbs.Text;
            return theParaGroupProducts;
        }

        protected void ImgSave_Click(object sender, ImageClickEventArgs e)
        {
            // lấy giá trị trên sesion  gán vào mảng
            ArrayList arr = (ArrayList)Session["ArrayListConfig"];
            for (int i = 0; i < arr.Count; i++)
            {
                ParaGroupProducts theParaGroupProducts = new ParaGroupProducts();
                ParaGroupProducts theParaGroup = new ParaGroupProducts();
                theParaGroup = GetParaGroupProducts(theParaGroupProducts);
                theParaGroup.GroupProductsID = Int32.Parse(arr[i].ToString());
                ThamSoProvider.UpdateParaGroupProducts(theParaGroup);
            }

            Response.Redirect("EHTCategory.aspx");
        }
    }
}